import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:im_base/public/tim/components/conversation/items/item.dart';

import '../logic.dart';
import 'logic.dart';

///已结束 问诊列表
class EndInquiryPage extends StatelessWidget {
  final logic = Get.put(EndInquiryLogic());
  final Function(String, String, bool) itemClick;

  EndInquiryPage(this.itemClick);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: GetBuilder<EndInquiryLogic>(
        init: logic,
        id: 'list',
        builder: (controller) {
          return ListView.builder(
              itemCount: logic.conversationList.length,
              itemBuilder: (context, index) {
                if (index == logic.conversationList.length - 2) {
                  logic.findLogic<ClassifyConversationLogic>().loadMore();
                }
                return ConversationItem(
                    key: ValueKey(
                        logic.conversationList[index]?.conversationID ?? ''),
                    itemData: logic.conversationList[index]!,
                    conversationClick: itemClick,
                    deleteItem: (data) => logic
                        .findLogic<ClassifyConversationLogic>()
                        .deleteConversation(data));
              });
        },
      ),
    );
  }
}
